import { reqGetSearchInfo } from '../../api'
// search模块的仓库
const actions = {
    // 第二个参数data默认是一个空对象
    async getSearchList({commit},data={}){
        let res = await reqGetSearchInfo(data)
        if(res.code === 200){
            commit("SEARCHLIST",res.data)
        }
    }
}
const mutations = {
    SEARCHLIST(state,searchList){
        state.searchList = searchList
    }
}
const state = {
    // 搜索模块数据
    searchList:{},
}

// 为了简化数据
const getters = {
    goodsList(state){
        // 网络出现故障时应该将返回值设置为空
        return state.searchList.goodsList||[]
    },
    attrsList(state){
        // 网络出现故障时应该将返回值设置为空
        return state.searchList.attrsList||[]
    },
    trademarkList(state){
        // 网络出现故障时应该将返回值设置为空
        return state.searchList.trademarkList||[]
    },
}

export default {
    state,
    mutations,
    actions,
    getters,
}
